#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "

insert into edu_dwb.dwb_customer_relationship_wide
select
         cr.id,
         cr.payment_time  ,
         cr.payment_state  ,
         cr.update_date_time  ,
         cr.deleted ,
         cr.customer_id ,
         cr.origin_type ,
         cr.itcast_clazz_id ,
         cr.origin_channel ,
         cr.creator,
         -- customer_clue
         cc.clue_state ,
         --empioyee
         e.tdepart_id ,
         --scrm_department
         sd.name ,
         --itcast_clazz
         ic.id as clazz_id,
         ic.itcast_school_id ,
         ic.itcast_school_name ,
         ic.itcast_subject_id,
         ic.itcast_subject_name ,
         --customer_appeal
         ca.appeal_status
from edu_dwd.fact_customer_relationship cr
left join edu_dwd.fact_customer_clue cc on cr.id = cc.customer_relationship_id
full join edu_dwd.dim_customer_appeal ca on cr.id = ca.id
left join edu_dwd.dim_empioyee e on cr.creator = e.id
left join edu_dwd.dim_itcast_clazz ic on cr.itcast_clazz_id = ic.id
left join edu_dwd.dim_scrm_department sd on e.tdepart_id = sd.id;